/*
* Conditions Of Use
*
* This software was developed by employees of the Sigmatrix(Beijing) Corporation.
* This software is provided by sigmatrix as a service and is expressly
* provided "AS IS."  Sigmatrix MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
* AND DATA ACCURACY.  Sigmatrix does not warrant or make any representations
* regarding the use of the software or the results thereof, including but
* not limited to the correctness, accuracy, reliability or usefulness of
* the software.
*
* Permission to use this software is contingent upon your acceptance
* of the terms of this agreement.
*
*/
package com.fileLoader.pojo;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

import com.fileLoader.pojo.mongo.FilePosition;
import com.fileLoader.pojo.mongo.FilePositionSetting;

/**
 * @ClassName: fileDict 文件字典
 * @Description: TODO()
 * @author libin
 * @date 2017年10月26日 上午11:55:41
 */
public class fileDict {
	public static void main(String[] args) {
		GenericXmlApplicationContext context = new GenericXmlApplicationContext();
		context.setValidating(false);
		context.load("classpath:spring/application-*.xml");
		context.refresh();
		MongoTemplate mongoTemplate = (MongoTemplate) context.getBean("mongoTemplate");
		Query query = Query.query(Criteria.where("status").is(1).and("writeFilePositions.status").is(1)
				.and("moveFilePositions.status").is(1));
		List<FilePositionSetting> list = mongoTemplate.find(query, FilePositionSetting.class);
		System.out.println(list.size());
		
//		FilePositionSetting filePositionSetting = new FilePositionSetting();
//		filePositionSetting.setBaseFileName("scan.log");
//		filePositionSetting.setStatus(1);
//		filePositionSetting.setCollectionName("scan");
//		filePositionSetting.setSettingTpye(1);
//		
//		List<FilePosition> filePositions = new ArrayList<FilePosition>();
//		FilePosition filePosition = new FilePosition();
//		filePosition.setDirectory("/scan");
//		filePosition.setPath("e:/data/logs");
//		filePosition.setStatus(1);
//		filePositions.add(filePosition);
//		
//		List<FilePosition> filePositions2 = new ArrayList<FilePosition>();
//		FilePosition filePosition2 = new FilePosition();
//		filePosition2.setDirectory("/scanHistory");
//		filePosition2.setPath("e:/data/logsHistory");
//		filePosition2.setStatus(1);
//		filePositions2.add(filePosition2);
//		
//		
//		filePositionSetting.setWriteFilePositions(filePositions);
//		filePositionSetting.setMoveFilePositions(filePositions2);
//		 mongoTemplate.save(filePositionSetting);
	}
}
// Logger logger = LoggerFactory.getLogger(com.fileLoader.pojo.fileDict.class);
//// File file = new File("e:\\data");
//// file.lastModified();
// Random random = new Random();
// while (true) {
// Integer aId = Integer.valueOf(random.nextInt(10));
// Integer mId = Integer.valueOf(random.nextInt(10));
// Integer eId = Integer.valueOf(random.nextInt(10));
// Integer pId = Integer.valueOf(random.nextInt(10));
// Integer cId = Integer.valueOf(random.nextInt(10));
// Integer dId = Integer.valueOf(random.nextInt(10));
// String uuid = UUID.randomUUID().toString().replaceAll("-", "");
// Scan scan = new Scan(mId, eId, pId, cId, dId, aId,DateUtil.getDateTimeStr(new
// Date()), "");
// String jsonObject = JSONObject.toJSONString(scan);
// logger.info(uuid +"-"+ jsonObject);
// }
//
// }